home *** CD-ROM | disk | FTP | other *** search
- Path: pub.news.uk.psi.net!usenet
- From: Matthew Towler <Matthew.Towler@unicam.co.uk>
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Sorting a list
- Date: 22 Mar 1996 12:29:51 GMT
- Organization: PSINet UK Public Usenet Site
- Message-ID: <4iu6g0$rsc@pub.news.uk.psi.net>
- NNTP-Posting-Host: 193.122.53.13
-
- mojaveg@ridgecrest.ca.us (Everett M. Greene) asks:
-
- > How does one alphabetize the pointers?
-
- You don't really, you alphabetise the strings using the pointers.
- Essentially you sort an array of pointers to the strings, as then
- when you wish to swap the positions of two strings you only need
- to move the pointers, rather than the whole strings. This also
- has the advantage that were you to sort an array of strings, all
- would have to be of the same length, or have the same amount of
- storage allocated. While the pointers approach means the strings
- can be totally different lengths; it even allows you to sort a list
- of string constants, without copying them to a variable string
- array, thus saving memory and time.
-
- To evaluate whether or not one string is higher in the alphabet you
- pass the pointers to strcmp().
-